package com.yiqi.zhiyuan.feature.home.view.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yiqi.zhiyuan.R;
import com.yiqi.zhiyuan.entity.vo.CarVO;

/**
 * @ProjectName: ZhiYuan
 * @Description: java类作用描述
 * @Author: lijuwen
 * @CreateDate: 2019/3/15 18:24
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/3/15 18:24
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class CarTypeAdapter extends BaseQuickAdapter<CarVO, BaseViewHolder> {
    private int mCheckPosition = -1;

    public CarTypeAdapter() {
        super(R.layout.item_dialog_service);
    }

    @Override
    protected void convert(BaseViewHolder helper, CarVO item) {
        helper.setBackgroundRes(R.id.ll_home_dialog, mCheckPosition == helper.getAdapterPosition() ? R.drawable.bg_home_dialog_checked : R.drawable.bg_home_dialog_uncheck)
                .setTextColor(R.id.tv_dialog_car_name, mCheckPosition == helper.getAdapterPosition() ? mContext.getResources().getColor(R.color.primary_comparison) : mContext.getResources().getColor(R.color.text_primary))
                .setTextColor(R.id.tv_dialog_car_no, mCheckPosition == helper.getAdapterPosition() ? mContext.getResources().getColor(R.color.text_car_no_select) : mContext.getResources().getColor(R.color.text_car_no_unselect))
                .setText(R.id.tv_dialog_car_name,item.getCarName())
                .setText(R.id.tv_dialog_car_no,item.getCarModelNo());
    }

    public void checkState(int position) {
        this.mCheckPosition = position;
        notifyDataSetChanged();
    }
}
